/**
 * 
 */
package org.database.filter.internal;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;

/**
 * @author tamnguyen
 * 
 */
public abstract class AbstractExceptionHandler<E extends Throwable> implements ExceptionMapper<E>
{

	@Override
	public final Response toResponse(E exception)
	{
		Error error = new Error();
		error.setStatus(Status.INTERNAL_SERVER_ERROR.getStatusCode());

		appendMessage(error, exception);

		return Response.ok().entity(error).build();
	}

	protected abstract void appendMessage(final Error error, E ex);

}
